#! /bin/bash
# 打开联网服务和蓝牙
systemctl start iwd.service
systemctl enable iwd.service
systemctl start systemd-resolved.service
systemctl enable systemd-resolved.service
systemctl enable bluetooth.service
systemctl enable NetworkManager
systemctl enable dhcpcd

# 配置网络和DNS
echo [General] >> /etc/iwd/main.conf
echo EnableNetworkConfiguration=true >> /etc/iwd/main.conf
echo NameResolvingService=systemd >> /etc/iwd/main.conf

# 安装了netwokmanager的配置, 使用iwd
echo [device] >> /etc/NetworkManager/NetworkManager.conf
echo wifi.backend=iwd >> /etc/NetworkManager/NetworkManager.conf

# 进入iwd连接wifi
iwctl

# CPU编码
if [ $1 == 'intel' ];then
	pacman -S intel-ucode		# intel
	if [ $1 == 'amd' ];then
		pacman -S amd-ucode	# amd
	fi
fi

# 独显驱动 nvidia
if [ $2 == 'nvidia' ];then	
	# （nvidia显卡驱动，用nvidia显卡就装，否则不用装）
	pacman -S mesa nvidia nvidia-settings nvidia-dkms nvidia-utils nvidia-prime
fi

# 显卡驱动
if [ $3 == 'intel' ];then
	pacman -S xf86-video-intel		# intel 核显
else
	if [ $3 =='amd' ];then
		pacman -S xf86-video-amdgpu	# amd 核显
	fi
fi

# 新建用户    (添加进入wheel用户组，并将bash作为启动命令)
useradd -m -G wheel -s /bin/bash lovectrl
passwd lovectrl

echo "[multilib]" >> /etc/pacman.conf
echo "Include = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf
echo "[archlinuxcn]" >> /etc/pacman.conf
echo "Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch" >> /etc/pacman.conf
pacman -S archlinuxcn-keyring
pacman -Syy

echo "GTK_IM_MODULE=fcitx" >> /etc/environment
echo "QT_IM_MODULE=fcitx" >> /etc/environment
echo "XMODIFIERS=@im=fcitx" >> /etc/environment

echo "root ALL=(ALL:ALL) ALL">> /etc/sudoers

echo "%wheel ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers

reboot
